package com.vhdadw.controller;

import com.vhdadw.controller.request.PayCallBackRequest;
import com.vhdadw.enums.ProductOrderPayTypeEnum;
import com.vhdadw.service.ProductOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/api/callback/order/v1")
public class PayCallBackController {

    @Autowired
    ProductOrderService productOrderService;

    @PostMapping("/wechat")
    public void wechatpayCallback(@RequestBody PayCallBackRequest payCallBackRequest) {

        Map<String, String> paramsMap = new HashMap<>(3);

        paramsMap.put("out_trade_no", payCallBackRequest.getOutTradeNo());
        //交易状态
        paramsMap.put("trade_state", payCallBackRequest.getTradeState());
        //用户编号
        paramsMap.put("account_no", payCallBackRequest.getAccountNo());


        productOrderService.processOrderCallbackMsg(ProductOrderPayTypeEnum.WECHAT_PAY, paramsMap);


    }


}
